package cn.doitedu.rtdw.udfs;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.flink.table.functions.ScalarFunction;

public class MyTimeTruncUdf extends ScalarFunction {

    public String eval(Long actionTime,Long interval){

        // 截断取整
        interval = (interval*60*1000);
        long trunked = (actionTime/interval) * interval;

        // 转为标准格式：  yyyy-MM-dd HH:mm:ss.SSS
        String format = DateFormatUtils.format(trunked, "yyyy-MM-dd HH:mm:ss.SSS");

        return format;
    }

}
